package com.huiquan.framework.utils;

import java.util.ArrayList;
import java.util.Arrays;

public class ArrayUtil<T> {

	/**
	 * 将数组根据分隔符拼凑成字符串
	 * 
	 */
	public static <T> String joinStringBySeparator(T[] array, String separator) {

		StringBuffer result = new StringBuffer();
		if (array != null && array.length > 0) {
			for (T t : array) {
				String str = t.toString();
				if (!str.isEmpty()) {
					result.append(str);
					result.append(separator);
				}
			}
			result.substring(result.length() - 1);
		}
		String str = result.toString();

		return str.substring(0, str.length() - 1);
	}

	/**
	 * 将数组转换为ArrayList
	 * 
	 * @param array
	 * @return
	 */
	public static <T> ArrayList<T> asList(T[] array) {

		return new ArrayList<T>(Arrays.asList(array));
	}
}
